/**
 * 
 */
package design_pattern.visitor;

import java.util.Enumeration;
import java.util.Vector;

/**
 * @author linzq
 * 
 */
public class ObjectStructure {

  private Vector nodes;

  private Node node;

  public ObjectStructure() {
    nodes = new Vector();
  }

  /**
   * 执行访问操作
   * 
   * @param visitor
   */
  public void action(Visitor visitor) {
    for (Enumeration e = nodes.elements(); e.hasMoreElements();) {
      node = (Node) e.nextElement();
      node.accept(visitor);
    }
  }

  public void add(Node node) {
    nodes.addElement(node);
  }

}
